﻿
@{
    Layout = null;
    var list = ViewData["olist"] as IList<Sc.Domain.CommOrgz>;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <link href="~/Content/css/style.css" rel="stylesheet" />
    <link href="~/Content/css/select.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/select-ui.min.js"></script>
    <script src="~/Content/layer-v2.1/layer/layer.js"></script>
    <script src="~/Scripts/comm.js"></script>
    <script type="text/javascript">
        $(document).ready(function (e) {
            $(".select2").uedSelect({
                width: 110
            });
            loadData($("#selOrgz").val(), "");
        });
        //数据加载
        function loadData(orgz, name) {
            var url = '@Url.Action("GetDriver", "CarInfo")';
            var load = loadTip("数据加载中，请稍候", 16, 0);
            $.get(url, { orgz: orgz, userName: name }, function (data) {
                var table = document.getElementById("listData");
                $("#listData").find("tr").remove();
                var tmp = '@ViewData["sigle"]'; var cate = "checkbox";
                if (tmp != undefined && tmp != null) {
                    cate = "radio";
                }
                $.each(data, function (index, n) {
                    var row = table.insertRow(table.rows.length);
                    row.Id = n.Id;
                    var cb = row.insertCell(0);
                    cb.innerHTML = "<input type='" + cate + "' tag=" + n.Id + " name='" + n.Name + "' />";
                    var name = row.insertCell(1);
                    name.innerHTML = n.Name;
                    var phone = row.insertCell(2);
                    phone.innerHTML = n.Phone;
                });
                $('.imgtable tbody tr:odd').addClass('odd');
                layer.close(load);
            });
        }
        //查询
        function search() {
            var orgz = $("#selOrgz").val();
            var name = $("#txtUserName").val();
            loadData(orgz, name);
        }
        //确定选择
        function sure() {
            var tmp = '@ViewData["sigle"]'; var cate = "checkbox";
            if (tmp != undefined && tmp != null) {
                cate = "radio";
            }
            var cbx = $("#listData").find("input[type=" + cate + "]:checked");
            if (cbx.length <= 0) {
                loadTip("请至少选择一个驾驶员", 2, 1000);
                return false;
            }
            var list = new Array();
            for (var i = 0; i < cbx.length; i++) {
                var ent = new Object();
                ent.Id = $(cbx[i]).attr("tag");
                ent.Name = $(cbx[i]).attr("Name");
                list.push(ent);
            }
            self.parent.sureDriver(list);
        }
    </script>
</head>
<body>
    <div class="rightinfo">
        <div class="tools">
            <ul class="toolbar">
                <li class="click" onclick="sure();"><span><img src="~/Content/images/t01.png" /></span>确定</li>
            </ul>
            <input type="hidden" id="busId" value="0" />
            <ul class="seachform" style="float:right;">
                <li>
                    <label>单位</label>
                    <div class="vocation">
                        <select name="select" class="select2" id="selOrgz">
                            @foreach (var item in list)
                            {
                                <option value="@item.Id">@item.OrgzName</option>
                            }
                        </select>
                    </div>
                </li>
                <li>
                    <label>姓名</label>
                    <input type="text" id="txtUserName" style="width:110px" class="scinput" />
                </li>
                <li>
                    <label>&nbsp;</label>
                    <input type="button" class="scbtn" onclick="loadData();" value="查询" />
                </li>
            </ul>
        </div>
        <table class="tablelist">
            <thead>
                <tr>
                    <th width="30px"></th>
                    <th>姓名</th>
                    <th>电话</th>
                </tr>
            </thead>
            <tbody id="listData"></tbody>
        </table>
    </div>
</body>
</html>
